import Vue from 'vue'
import VueRouter from 'vue-router'
import LoginView from '../views/LoginView.vue'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        component: LoginView,
        meta: {
            title: '用户登录'
        },
    },
    {
        path: '/reg',
        name: 'Reg',
        component: () =>import('../views/Reg.vue'),
        meta: {
            title: '用户注册'
        }
    },
    {
        path: '/admin',
        redirect:'/admin/home',  /**重定向*/
        component: () => import('../views/AdminView.vue'),
        children:[

            /** 首页*/
            {
                path: '/admin/home',
                name: 'Home',
                component: () => import('../views/admin/Home.vue')
            },

            /** 零售管理模块*/
            {
                //零售出库
                path:'/admin/retailOut-warehouse',
                name:'RetailOutWarehouse',
                component: () => import('../views/admin/retail-hr/RetailOutWarehouse .vue')
            },
            {
                //零售退货
                path:'/admin/retail-return',
                name:'RetailReturn',
                component: () => import('../views/admin/retail-hr/RetailReturn.vue')
            },
            /** 零售管理模块结束*/

            /**仓库管理模块开始*/
            {
                /*组装单*/
                path:'/AssemblyList',
                name:'AssemblyList',
                component: () => import('../views/admin/storehouse-my/AssemblyList.vue')
            },
            {
                /*拆卸单*/
                path:'/DisassemblyList',
                name:'DisassemblyList',
                component: () => import('../views/admin/storehouse-my/DisassemblyList.vue')
            },
            {
                /*其它出库*/
                path:'/OtherOutbound',
                name:'OtherOutbound',
                component: () => import('../views/admin/storehouse-my/OtherOutbound.vue')
            },

            {
                /*其它入库*/
                path:'/OtherStorage',
                name:'OtherStorage',
                component: () => import('../views/admin/storehouse-my/OtherStorage.vue')
            },
            {
                /*调拨出库*/
                path:'/TransferOut',
                name:'TransferOut',
                component: () => import('../views/admin/storehouse-my/TransferOut.vue')
            },
            /**仓库管理模块结束*/

            /**财务模块开始*/
            {
                /*收入单*/
                path:'/admin/finance/income',
                name:'income',
                component: () => import('../views/admin/finance/income.vue')
            },
            {
                /*支出单*/
                path:'/admin/finance/expense',
                name:'expense',
                component: () => import('../views/admin/finance/expense.vue')
            },
            {
                /*收款单*/
                path:'/admin/finance/proceeds',
                name:'proceeds',
                component: () => import('../views/admin/finance/proceeds.vue')
            },

            {
                /*付款单*/
                path:'/admin/finance/payment',
                name:'OtherStorage',
                component: () => import('../views/admin/finance/payment.vue')
            },
            {
                /*转账单*/
                path:'/admin/finance/transfer',
                name:'TransferOut',
                component: () => import('../views/admin/finance/transfer.vue')
            },
            {
                /*收预付款*/
                path:'/admin/finance/advance_payment',
                name:'TransferOut',
                component: () => import('../views/admin/finance/advance_payment.vue')
            },
            /**仓库管理模块结束*/

            /** 采购管理模块开始*/

            {
                /*采购订单*/
                path:'/PO',
                name:'PO',
                component: () => import('../views/admin/PurchasingManagement-ct/PO')
            } ,
            {
                /*采购入库*/
                path:'/PS',
                name:'PS',
                component: () => import('../views/admin/PurchasingManagement-ct/PS')
            },
            {
                /*采购退货*/
                path:'PS',
                name:'PS',
                component: () => import('../views/admin/PurchasingManagement-ct/PR')
            },
            /** 采购管理模块结束*/

            /** 生产管理模块开始*/
            {
                path:'/PT',
                name:'PT',
                component: () => import('../views/admin/productionmanagement/PT')
            },{
                path: '/DOM',
                name:'DOM',
                component: () => import('../views/admin/productionmanagement/DOM')
            },
            /** 生产管理模块结束*/

            /*商品管理开始*/
            {
                /*商品类别*/
                path: '/MerchandiseCategories',
                name: 'MerchandiseCategories',
                component: () => import('../views/admin/merchandise-control/MerchandiseCategories.vue')
            },
            /*商品信息*/
            {
                path: '/CommodityInformation',
                name:'CommodityInformation',
                component: () => import('../views/admin/merchandise-control/CommodityInformation.vue')
            },
            /*计量单位*/
            {
                path: '/MeasuringUnit',
                name:'MeasuringUnit',
                component:() => import('../views/admin/merchandise-control/MeasuringUnit.vue')
            },
            /*多属性*/
            {
                path: '/MultiAttribute',
                name: 'MultiAttribute',
                component: () => import('../views/admin/merchandise-control/MultiAttribute.vue')
            }
        ]
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})

export default router
